{{>licenseInfo}}
{{#operations}}

#include "{{classname}}Impl.h"

{{#apiNamespaceDeclarations}}
namespace {{this}} {
{{/apiNamespaceDeclarations}}

{{#hasModelImport}}
using namespace {{modelNamespace}};
{{/hasModelImport}}

{{classname}}Impl::{{classname}}Impl(const std::shared_ptr<Pistache::Rest::Router>& rtr)
    : {{classname}}(rtr)
{
    {{#authMethods}}{{#isBasicBasic}}/*

    Http Basic Auth
    ===============

    Do this in the individual classes in the constructor

    this->setBasicCredentialsAuthenticator(
        [](HttpBasicCredentials &credentials)->bool
        {
            if(credentials.user == "foo" && credentials.password == "bar")
            {

                const int userIdOfFoo = 66;
                credentials.userdata = std::unique_ptr<void, std::function<void(void*)>> (
                    reinterpret_cast<void*>(new int(userIdOfFoo)),
                    [&](void* ptr)
                    {
                        int * value = reinterpret_cast<int*>(ptr);
                        delete value;
                    }
                );
                return true;
            }
            return false;
        }
        );

    or in main:

    for (auto api : apiImpls) {
        api->init();

        api->setBasicCredentialsAuthenticator(
        []( HttpBasicCredentials &credentials)->bool
        {
            if(credentials.user == "foo" && credentials.password == "bar")
            {

                const int userIdOfFoo = 66;
                credentials.userdata = std::unique_ptr<void, std::function<void(void*)>> (
                    reinterpret_cast<void*>(new int(userIdOfFoo)),
                    [&](void* ptr)
                    {
                        int * value = reinterpret_cast<int*>(ptr);
                        delete value;
                    }
                );
                return true;
            }
            return false;
        }
        );
    }

    or a mix.

    Until you do either, protected resources will result in a 401.
    */{{/isBasicBasic}}
    {{#isBasicBearer}}/*

    Http Basic Bearer
    ===============

    Do this in the individual classes in the constructor

    this->setBearerTokenAuthenticator(
        [](HttpBearerToken &token)->bool
        {
            if(token.token == "Zm9vYmFyCg==")
            {
                const int userIdOfFoo = 99;
                token.userdata = std::unique_ptr<void,std::function<void(void*)>>(
                    reinterpret_cast<void*>(new int(userIdOfFoo)),
                    [&](void* ptr)
                    {
                        int * value = reinterpret_cast<int*>(ptr);
                        delete value;
                    }
                );
                return true;
            }
            return false;
        }
        );

    or in main:

    for (auto api : apiImpls) {
        api->init();

        api->setBearerTokenAuthenticator(
        [](HttpBearerToken &token)->bool
        {
            if(token.token == "Zm9vYmFyCg==")
            {
                const int userIdOfFoo = 99;
                token.userdata = std::unique_ptr<void,std::function<void(void*)>>(
                    reinterpret_cast<void*>(new int(userIdOfFoo)),
                    [&](void* ptr)
                    {
                        int * value = reinterpret_cast<int*>(ptr);
                        delete value;
                    }
                );
                return true;
            }
            return false;
        }
        );
    }

    or a mix.

    Until you do either, protected resources will result in a 401.
    */{{/isBasicBearer}}
    {{/authMethods}}

}

{{#operation}}
{{#vendorExtensions.x-codegen-pistache-is-parsing-supported}}
void {{classname}}Impl::{{operationIdSnakeCase}}({{#authMethods}}{{#isBasicBasic}}const HttpBasicCredentials &credentials, {{/isBasicBasic}}{{#isBasicBearer}}const HttpBearerToken &bearerToken, {{/isBasicBearer}}{{/authMethods}}{{#allParams}}const {{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) {
    response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
{{^vendorExtensions.x-codegen-pistache-is-parsing-supported}}
void {{classname}}Impl::{{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) {
    response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
{{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
{{/operation}}

{{#apiNamespaceDeclarations}}
}
{{/apiNamespaceDeclarations}}

{{/operations}}
